import random
import cards

from abstract_player import AbstractPlayer
from math import sqrt

class ArtificialPlayer2(AbstractPlayer):
    def __init__(self, game, name, bluffing = 0):
        AbstractPlayer.__init__(self)
        
        self.game = game
        self.name = name
        self.bluffing = bluffing
        
    def do_move(self):
        probability = self.get_simple_probability()
        
        if self.game.checkable(self.current_bet):
            if random.random() < self.bluffing:
                self.bet(self.game.pot)            
            if probability > 0.5:
                self.bet(self.game.pot)
            else:
                self.check()
        else:
            ratio = probability/self.pot_odds()
                        
            if ratio > 1.5:
                self.raise_amount(max(self.game.pot, self.game.min_raise()))
            elif ratio > 1:
                self.call()
            else:
                self.fold()
    
    def __str__(self):
        return self.name + " (a2)"